﻿using AIWeb.Models.PhonetTableAdapters;
using System;
using System.Linq;
using System.Web.Mvc;

namespace AIWeb.Controllers
{
    public class HomeController : Controller
    {
        [Route("Home/Index")]
        public ActionResult Index()
        {
            ViewBag.Title = "Home Page";

            return View();
        }

        //[Route("Home/Hello")]
        public String Phone(string id)
        {
            string number = id.Substring(0, 7);
            PhonetmpTableAdapter adapter = new PhonetmpTableAdapter();
            var row = adapter.GetDataByNumber(number).First();
            return $"{row.Province}\r\n{row.Area}\r\n{row.Provider}\r\n";
            //return "Hello\r\nWorld\r\n";
        }

        public String Weather(string id)
        {
            WeatherTableAdapter ada = new WeatherTableAdapter();
            var row = ada.GetData().Single(x => x.ID == id);
            return $"{row.Name}\n{row.Summary}\n{row.LowTemp}\n{row.HighTemp}";
        }
    }
}
